package com.cyc.common.enums;

import lombok.Getter;

import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 创意词包
 *
 * @author : zhangsq
 * @date : 2020/11/08
 **/
public enum OceCreativeWordEnum {

    REGION(4,4,"地点","{地点}"),
    DATE(1727,2,"日期","{日期}"),
    WEEK(1736,3,"星期","{星期}"),
    AGE(1737,3,"年龄","{年龄}");

    @Getter
    private Integer creativeWordId;
    @Getter
    private Integer maxWordLen;
    @Getter
    private String name;
    @Getter
    private String alias;

    //获取动态词包列表
    public static List<Map<String, Object>> getCreativeWordList() {
        List<Map<String, Object>> list = new ArrayList<>();
        OceCreativeWordEnum[] creativeWordEnums  = OceCreativeWordEnum.values();
        for (OceCreativeWordEnum e : creativeWordEnums) {
            Map<String, Object> map = new HashMap<>();
            map.put("creativeWordId", e.getCreativeWordId());
            map.put("maxWordLen", e.getMaxWordLen());
            map.put("name", e.getName());
            map.put("alias", e.getAlias());
            list.add(map);
        }
        return list;
    }

    /**
     * 获取词包和词包id集合Map
     * @return
     */
    public static HashMap<String,Integer> getAliaAndIdMap() {
        HashMap<String, Integer> map = new HashMap<>();
        for (OceCreativeWordEnum oceCreativeWordEnum : EnumSet.allOf(OceCreativeWordEnum.class)) {
            map.put(oceCreativeWordEnum.alias, oceCreativeWordEnum.creativeWordId);
        }
        return map;
    }

    OceCreativeWordEnum(Integer creativeWordId, Integer maxWordLen, String name, String alias) {
        this.creativeWordId = creativeWordId;
        this.maxWordLen = maxWordLen;
        this.name = name;
        this.alias = alias;
    }
}
